package com.gbs.flash.api.controller.shop;

import com.gbs.flash.bean.constant.factory.PageFactory;
import com.gbs.flash.bean.entity.shop.OrderLog;
import com.gbs.flash.bean.vo.front.Rets;
import com.gbs.flash.bean.vo.query.SearchFilter;
import com.gbs.flash.service.shop.OrderLogService;
import com.gbs.flash.utils.factory.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "订单日志管理", tags = "商品订单管理")
@RestController
@RequestMapping("/shop/order/log")
public class OrderLogController {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private OrderLogService orderLogService;

    @ApiOperation("查询订单所有日志")
    @RequestMapping(value = "/queryByIdOrder/{idOrder}", method = RequestMethod.GET)
    public Object queryByIdOrder(@PathVariable("idOrder") Long idOrder) {
        List<OrderLog> logList = orderLogService.queryAll(SearchFilter.build("idOrder", idOrder));
        return Rets.success(logList);
    }

    @ApiOperation("查询所有订单日志")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Object list() {
        Page<OrderLog> page = new PageFactory<OrderLog>().defaultPage();
        page = orderLogService.queryPage(page);
        return Rets.success(page);
    }
}
